Try different protocols against union in question#4333
Conversation
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
ysaito1001
left a comment
There was a problem hiding this comment.
Nice work! Changes to QuerySerializerGenerator look good.
For the changes to the tests (AwsQueryTest, RestJsonTest, and RestXmlTest), we should keep the existing ones untouched and add new tests with separate test models. Feel free to rename SSES3Filter in test models to something that sounds like one-off, test-specific; it's totally fine if we don't preserve type name from s3control at this point.
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
ysaito1001
left a comment
There was a problem hiding this comment.
LGTM. Would like to rename test models a bit and simplify them. Once that's done, we're good to go!
.../src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQueryTest.kt
Outdated
Show resolved
Hide resolved
.../src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQueryTest.kt
Outdated
Show resolved
Hide resolved
.../src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQueryTest.kt
Outdated
Show resolved
Hide resolved
.../src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJsonTest.kt
Show resolved
Hide resolved
| } | ||
|
|
||
| @Test | ||
| fun `union with empty struct always uses inner variable`() { |
| } | ||
|
|
||
| @Test | ||
| fun `union with empty struct generates warning-free code`() { |
...t/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXmlTest.kt
Show resolved
Hide resolved
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
…ith empty structs - Add isEmptyStruct() helper to detect empty struct shapes - Use _inner for empty structs to avoid unused variable warnings - Use inner for non-empty structs where variable is used - Add comprehensive tests for RestXml, AwsQuery, and RestJson protocols - Tests enforce -D warnings via clientIntegrationTest
Prefix writer with underscore when union contains only empty structs
When building tests, discovered that serializeUnion was using incorrect variable name for empty struct members. The pattern match correctly used '_inner' but serializeMember was called with 'inner', causing compilation errors. Fixed by passing the correct variable name based on whether the struct is empty.
- Rename modelWithEmptyStruct to inputUnionWithEmptyStructure - Remove output parameter and TestOutput structure - Focus tests on input serialization only
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
Motivation and Context
Fixes unused variable warnings in RestXml/AwsQuery union serializers when variants contain empty structs. Discovered in S3Control's
ObjectEncryptionFilter. Builds with-D warningswere failing.Previous attempt fixed all serializers, but only RestXml/AwsQuery need it.
RestJson/CBOR always reference the inner variable.
Description
Modified
QuerySerializerGeneratorto prefix unused variables with underscore for empty struct variants:isEmptyStruct()to detect empty structures_innerfor empty structs,innerfor non-empty structsTesting
Added tests for RestXml, AwsQuery, and RestJson (documents immunity)
Tests enforce
-D warningsviaclientIntegrationTestVerified S3Control compiles cleanly with
RUSTFLAGS="-D warnings"By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.